#include<stdio.h>
#include<stdlib.h>

typedef struct node{
	int d;
	struct node* n;
}node;

node* is(){
	node* s=(node*)malloc(sizeof(node));
	s->d=0;
	s->n=NULL;
	return s;
}

node* in(int d){
	node* n=(node*)malloc(sizeof(node));
	n->d=d;
	n->n=NULL;
}

int ie(node* s){
	return s->d==0 || s->n==NULL;
}

int pop(node* s){
	if(ie(s)){
		return -1;
	}else{
		node* cur=s->n;
		s->n=cur->n;
		s->d--;
		int ret=cur->d;
		free(cur);
		return ret;
	}
}

void push(node*s,int d){
	node* n=in(d);
	n->n=s->n;
	s->n=n;
	s->d++;
}

void ps(node*s){
	node* cur=s->n;
	while(cur){
		printf("%d ",cur->d);
		cur=cur->n;
	}
	printf("\n");
}


int main()
{
	node*s=is();
	push(s,1);
	push(s,2);
	push(s,3);
	push(s,4);
	push(s,5);
	int ret=pop(s);
	printf("%d\n",ret);
	printf("hello world");
	ps(s);
}
